<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #template {
            display: none;
        }
        
        a {
            text-decoration: none;
            color: #e99;
        }
        
        li {
            list-style: disc;
        }
        
        a:hover {
            text-decoration: underline;
        }
    </style>
</head>

<body>
    <ul>
        <li id="template">
            <a href="detail.html" target="_blank"></a>
        </li>
    </ul>
    <script src="jquery.min.js">
    </script>
    <script>
        // $.ajax({
        //         url: "http://10.35.170.82:8080/getnewslist",
        //         data: {
        //             id: location.href.parseUrl().id,
        //         },
        //         success(data) {
        //             data.forEach(item => {

        //                 let newtemplate = $("#template").clone()
        //                 newtemplate.attr("id", "").find("a").html(item.title).attr('href', `detail.html?${item.id}`)
        //                 newtemplate.appendTo($("ul"))

        //             })
        //         }
        //     })
        let http = new XMLHttpRequest()
        http.open('get', "http://10.35.170.82:8080/getnewslist")
        http.send()
        http.onreadystatechange = function() {
            if (http.readyState === 4) {
                let data = JSON.parse(http.responseText)
                let tem = $("#template")
                let list = $("#list")
                data.forEach(item => {
                    let newItem = tem.clone();
                    newItem.attr("id", "").find("a").html(item.title).attr('href', `detail.html?id=${item.id}`)
                    newItem.appendTo($("ul"))
                })
            }
        }
    </script>
</body>

</html>